

//
//  LJHCateTableViewCell.m
//  HEARME
//
//  Created by 曲政永 on 16/1/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHCateTableViewCell.h"
#import "LJHCateModel.h"
#import "UIImageView+WebCache.h"
@interface LJHCateTableViewCell ()

@property(nonatomic,retain)UIImageView *imvVoice;
@property(nonatomic,retain)UIImageView *imvMusic;
@property(nonatomic,retain)UIImageView *imvHappy;
@property(nonatomic,retain)UIImageView *imvBook;
@property(nonatomic,retain)UIImageView *imvChild;

@end

@implementation LJHCateTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createCell];
    }
    return self;
}

-(void)createCell
{

    self.imvVoice = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, (WIDTH-20)/2, (WIDTH-20)/2)];
    self.imvVoice.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imvVoice];

    
    self.imvMusic = [[UIImageView alloc]initWithFrame:CGRectMake(15+(WIDTH-20)/2, 10, ((WIDTH-20)/2-10)/2, ((WIDTH-20)/2-10)/2)];
    self.imvMusic.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imvMusic];
    
    self.imvHappy = [[UIImageView alloc]initWithFrame:CGRectMake((15+(WIDTH-20)/2)+((WIDTH-20)/2-10)/2+5, 10, ((WIDTH-20)/2-10)/2, ((WIDTH-20)/2-10)/2)];
    self.imvHappy.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imvHappy];
    
    self.imvBook = [[UIImageView alloc]initWithFrame:CGRectMake(15+(WIDTH-20)/2, 10+((WIDTH-20)/2-10)/2+8, ((WIDTH-20)/2-10)/2, ((WIDTH-20)/2-10)/2)];
    self.imvBook.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imvBook];
    
    self.imvChild = [[UIImageView alloc]initWithFrame:CGRectMake((15+(WIDTH-20)/2)+((WIDTH-20)/2-10)/2+5, 10+((WIDTH-20)/2-10)/2+8, ((WIDTH-20)/2-10)/2, ((WIDTH-20)/2-10)/2)];
    self.imvChild.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.imvChild];

    
}
-(void)setCateArray:(NSMutableArray *)cateArray
{
    if (_cateArray!=cateArray) {
        [_cateArray release];
        _cateArray = [cateArray retain];
    }
    LJHCateModel *cateModel = [self.cateArray objectAtIndex:0];
    NSURL *urlVoice = [NSURL URLWithString:cateModel.coverPath];
    [self.imvVoice sd_setImageWithURL:urlVoice placeholderImage:[UIImage imageNamed:@"1024.jpg"]];
    LJHCateModel *musicModel = [self.cateArray objectAtIndex:1];
    NSURL *urlMusic = [NSURL URLWithString:musicModel.coverPath];
    [self.imvMusic sd_setImageWithURL:urlMusic placeholderImage:[UIImage imageNamed:@"1024.jpg"]];
    LJHCateModel *happyModel = [self.cateArray objectAtIndex:2];
    NSURL *urlHappy = [NSURL URLWithString:happyModel.coverPath];
    [self.imvHappy sd_setImageWithURL:urlHappy placeholderImage:[UIImage imageNamed:@"1024.jpg"]];
    LJHCateModel *bookModel = [self.cateArray objectAtIndex:3];
    NSURL *urlBook = [NSURL URLWithString:bookModel.coverPath];
    [self.imvBook sd_setImageWithURL:urlBook placeholderImage:[UIImage imageNamed:@"1024.jpg"]];
    LJHCateModel *childModel = [self.cateArray objectAtIndex:4];
    NSURL *urlChild = [NSURL URLWithString:childModel.coverPath];
    [self.imvChild sd_setImageWithURL:urlChild placeholderImage:[UIImage imageNamed:@"1024.jpg"]];
    
    UITapGestureRecognizer *tapIV = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(push:)];
    [self.imvVoice addGestureRecognizer:tapIV];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
